package TimeDateClass;

import org.junit.Test;

import java.util.Date;

/**
 * @author 李泽伟
 */
public class Main {
    public static void main(String[] args) {
        // 1.currentTimeMillis当前时间：毫秒1666010742126
        long time = System.currentTimeMillis();
        System.out.println(time);
        // 2.Java.util.Date类
        // 构造器1：创建当前时间的Date对象
        Date date = new Date();
        // Mon Oct 17 20:41:13 CST 2022 CST:China Standard Time == GMT+8/UTC+8
        System.out.println(date.toString());
        //date.getTime()获取毫秒数
        System.out.println(date.getTime());
        //构造器2：创建指定毫秒数的Date对象 Mon Oct 17 20:45:42 CST 2022
        Date date1 = new Date(1666010742126L);
        System.out.println(date1);

        //Java.sql.Date对应数据库中的数据对象date -> 2022-10-17
        java.sql.Date date2 = new java.sql.Date(1666010742126L);
        System.out.println(date2);

        //Java.util.Date对象和Java.sql.Date对象的转换 public class Date extends java.util.Date 是Util类的子类
        Date date3 = new Date();
        java.sql.Date date4 = new java.sql.Date(date3.getTime());
        System.out.println(date4);
    }

    public String reverse(String str, int start, int end){
        if (str!=null){
            char[] charArr = str.toCharArray();
            for (int i = start, j=end; i < j; i++,j--){
                char tem = charArr[j];
                charArr[i] = charArr[j];
                charArr[j] = tem;
            }
            return new String(charArr);
        }
        return null;
    }
    @Test
    public void test(){
        String s = reverse("abcde", 1, 3);
        System.out.println(s);
    }
}
